﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Site.Master" AutoEventWireup="true" CodeBehind="ChatList.aspx.cs" Inherits="VK.Casemeet.Web.Admin.Chats.ChatList" %>

<%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %>
<%@ Import Namespace="VK.Comm" %>
<asp:Content ID="Content1" ContentPlaceHolderID="contentHead" runat="server">
    <script type="text/javascript">
        $("document").ready(function () {
            if (<% =area1 %> == 0) {
                BindArea(0, "#ddlArea1", 0, 0);
            } else {
                BindArea(0, "#ddlArea1", <% =area1 %>, <% =area2 %>);
            }
        });

        function BindArea(parentID, ddlControl, area1, area2) {
            $.ajax({
                type: "post",
                url: "/Admin/CommService.asmx/GetArea",
                dataType: "json",
                contentType: "application/json;charset=utf-8",
                data: "{ \"parentID\":" + parentID + " }",
                beforeSend: function (jsonHttpRequest) {
                    this;
                },
                success: function (jsonHttpRequest, textStatus) {
                    var temp_option = new String;
                    temp_option += "<option value=\"0\">全部</option>";
                    if (ddlControl == "#ddlArea1") { temp_option = fillOption(temp_option, jsonHttpRequest, area1); }
                    if (ddlControl == "#ddlArea2" && parentID != "0") { temp_option = fillOption(temp_option, jsonHttpRequest, area2); }
                    $(ddlControl).html(temp_option);
                    if (ddlControl == "#ddlArea1") {
                        BindArea($(ddlControl).val(), "#ddlArea2", area1, area2);
                    }
                },
                error: function (jsonHttpRequest, textStatus, errorThrown) {
                    this;
                },
                complete: function (jsonHttpRequest, textStatus) {
                    this;
                }
            });
        }
        function area1_onchange() {
            if ($("#ddlArea1").val() != "0") {
                $("#ddlArea2").html("");
                $("#hidArea").val($("#ddlArea1")[0].options[$("#ddlArea1")[0].selectedIndex].text);
                BindArea($("#ddlArea1").val(), "#ddlArea2", 0, 0, 0);
            }
        }
        function area2_onchange() {
            if ($("#ddlArea2").val() != "0") {
                $("#hidArea").val($("#ddlArea1")[0].options[$("#ddlArea1")[0].selectedIndex].text + " " + $("#ddlArea2")[0].options[$("#ddlArea2")[0].selectedIndex].text);
            }
        }
        function fillOption(temp_option, jsonHttpRequest, area) {
            $.each(jsonHttpRequest.d, function (i, field) {
                if (area == field.AreaID) {
                    temp_option += "<option selected value=\"" + field.AreaID + "\">" + field.Name + "</option>";
                } else {
                    temp_option += "<option value=\"" + field.AreaID + "\">" + field.Name + "</option>";
                }
            });
            return temp_option;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="contentBody" runat="server">
    <div class="bodyContent divBody">
        <div class="divListOper">
            <a class="tableOperNew" href="ChatAdd.aspx">新建客服</a>
        </div>
        <div class="divSearch">
            <div class="ico"></div>
            <div class="content">
                <div class="padlef10" style="width:200px;<% =display %>">
                    地区: 
                    <select id="ddlArea1" name="ddlArea1" onchange="area1_onchange();" class="selectddl" style="width:auto;"></select>
		            <select id="ddlArea2" name="ddlArea2" onchange="area2_onchange();" class="selectddl" style="width:auto;"></select>
                </div>
                <div style="width:250px;">
                    名称: <asp:TextBox ID="txtName" runat="server" Width="200" CssClass="inputText"></asp:TextBox>
                </div>
            </div>
            <div class="search" style="width:80px;">
                <asp:Button ID="butSearch" runat="server" CssClass="inputbutSearch" Text="搜 索 >>" onclick="butSearch_Click" />
            </div>
        </div>

        <asp:Repeater ID="rptChat" runat="server" onitemcommand="rptChat_ItemCommand">
        <HeaderTemplate>
        <table class="tableList" cellspacing="0">
            <thead>
                <tr>
                    <th>编号</th>
                    <th>QQ号码</th>
                    <th>名称</th>
                    <th>所属地区</th>
                    <th>创建时间</th>
                    <th>排序</th>
                    <th>启用</th>
                    <th style="width:110px;"><span>操作</span></th>
                </tr>
            </thead>
            <tbody>
        </HeaderTemplate>
        <ItemTemplate>
                <tr>
                    <td><%# Eval("ChatID")%></td>
                    <td><%# Eval("Number")%></td>
                    <td><%# Eval("Name")%></td>
                    <td><%# Eval("ProvinceName").ToString() + "-" + Eval("CityName").ToString()%></td>
                    <td><%# Util.FormatDateTime((DateTime)Eval("Created"), DateTimeStyle.ShortDate2)%></td>
                    <td><%# Eval("Sort")%></td>
                    <td class="txtcen"><%# VK.Casemeet.PageHelper.GetIsEnableLabel((bool)Eval("IsEnable"))%></td>
                    <td class="txtcen">
                        <a class="left tableOperEdit" href="ChatEdit.aspx?ChatID=<%# Eval("ChatID")%>">&nbsp;</a>
                        <asp:LinkButton CssClass="left tableOperDelete" ID="butDelete" CommandName="Delete" CommandArgument='<%# Eval("ChatID")%>' runat="server" OnClientClick="return confirm('您确定要删除吗？删除后将不可恢复！');">&nbsp;</asp:LinkButton>
                    </td>
                </tr>
        </ItemTemplate>
        <FooterTemplate>
            </tbody>
        </table>
        </FooterTemplate>
        </asp:Repeater>
        
        <webdiyer:AspNetPager ID="aspNetPager" runat="server" CssClass="paginator" CurrentPageButtonClass="cpb" 
            onpagechanged="aspNetPager_PageChanged" PageIndexBoxType="DropDownList" PageSize="20" SubmitButtonText="Go" 
            TextAfterPageIndexBox="页" TextBeforePageIndexBox="转到" 
            CustomInfoHTML="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;共%RecordCount%条, 每页%PageSize%条, <font style='color:#A36D33;'>%currentPageIndex%</font>/%pageCount%页" 
            ShowCustomInfoSection="Left" CustomInfoSectionWidth="580px" NumericButtonCount="5">
        </webdiyer:AspNetPager>
    </div>
</asp:Content>